//package com.woniuxy.lab.woniu_lab.mqListener;
//
//import com.woniuxy.lab.woniu_lab.commons.Mail;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
//import org.apache.rocketmq.spring.core.RocketMQListener;
//import org.springframework.mail.javamail.JavaMailSender;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import javax.mail.MessagingException;
//import javax.mail.internet.InternetAddress;
//
//import javax.mail.internet.MimeMessage;
//@Slf4j
//@Component
//@RocketMQMessageListener(topic = "send_email_topic",consumerGroup = "email")
//public class EmailListener implements RocketMQListener<Mail> {
//    @Resource
//    private JavaMailSender javaMailSender;
//    @Override
//    public void onMessage(Mail mail) {
//        MimeMessage message = javaMailSender.createMimeMessage();
//
//        try {
//            message.setFrom(new InternetAddress("a731245743@163.com"));
//
//            message.setRecipient(javax.mail.Message.RecipientType.TO,new InternetAddress(mail.getUserEmail()));
//
////            设置发送内容
//            message.setText(mail.getText());
//            //设置标题
//            message.setSubject(mail.getText());
//            //发送邮箱
//            javaMailSender.send(message);
//
//            log.info("邮箱发送成功");
//        } catch (MessagingException e) {
//            throw new RuntimeException(e);
//        }
//    }
//}
